This page last changed on May 17, 2009 by scytacki.

Setting environment variables in the .profile file on OSX does not affect applications launched from the GUI. For example running eclipse from the GUI it doesn't pick up variables set in the .profile file.
This page provides info on this: http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-113982

As documented in the above link creating the file below and putting your path in it will do the trick:

~/.MacOSX/environment.plist

A few pointers:

  • you can use the plist editor to create the file, do:
    touch ~/.MacOSX/environment.plist
    open ~/.MacOSX/environment.plist
    
  • you need to make a root element and then add a PATH sub element
  • there does not appear a way to inherit any global PATH settings so you need to start with the defaults
  • for me that was:
    /usr/bin:/bin:/usr/sbin:/sbin
  • when you launch a shell OSX will add to this with its global "shell" path info which is in the file:
    /etc/paths
  • then it will add paths from files inside of the folder
    /etc/paths.d/
  • when it does this adding, it checks if those folders are already on the path and doesn't add them if they are.
  • finally after this it loads your .profile and .bash_rc (I'm not sure the order or methods for those)
  • environment variables are not expanded in the environment.plist so if you try to do
    $HOME/bin
    it won't do you what you want.
Document generated by Confluence on Jan 27, 2014 16:52